package cn.edu.xhu.library_management.user.client;

import cn.edu.xhu.library_management.common.entity.R;
import cn.edu.xhu.library_management.user.entity.LmBorrow;
import cn.edu.xhu.library_management.user.entity.LmReservation;
import cn.edu.xhu.library_management.user.entity.dto.BookRecordDTO;
import cn.edu.xhu.library_management.user.entity.pojo.LmBook;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: MMJ
 * @Date: 2023 - 04 - 23
 * @Description:
 */
@FeignClient("lmBook")
public interface BookClient {
    // 通过图书ID查询详细信息
    @GetMapping("/lm_book/book/{bookId}")
    public R findBookDetail(@PathVariable("bookId") Long bookId);

    //    通过父类查询子类
    @GetMapping("/lm_book/category/{pid}")
    public R findCategoryByPid(@PathVariable(name = "pid") Long pid);

    // 通过分类查询图书 只查一级分类
    @GetMapping("/lm_book/book/category/{pid}")
    public R findBookByCategory(@PathVariable("pid") Integer pid);

    // 查询用户已归还借阅记录
    @GetMapping("/lm_book/borrow/re/{account}")
    public List<BookRecordDTO> reBorrow(@PathVariable("account") String account);

    // 查询用户未归还借阅记录
    @GetMapping("/lm_book/borrow/noRe/{account}")
    public List<BookRecordDTO> noReBorrow(@PathVariable("account") String account);

    // 预约图书
    @PostMapping("/lm_book/reservation")
    public boolean reservation(@RequestBody LmReservation reservation);

    // 获取预约图书记录
    @GetMapping("/lm_book/reservation")
    public List<BookRecordDTO> getReservationBook(@RequestParam("userAccount") String userAccount);

    // 删除预约记录
    @DeleteMapping("/lm_book/reservation/{id}")
    public boolean delReservation(@PathVariable("id") Integer id);

    // 借阅图书
    @PostMapping("/lm_book/borrow")
    public boolean borrowBook(@RequestBody LmBorrow borrow);
}
